package operation;

import House.*;

import java.util.Scanner;

public class Addoperation implements Inoperation{
    Scanner scanner=new Scanner(System.in);
    @Override
    public void work(HouseList houseList) {
        System.out.println("========添加房屋========");
        System.out.println("姓名:");
        String name=scanner.nextLine();
        System.out.println("电话：");
        String phone=scanner.nextLine();
        System.out.println("地址");
        String address=scanner.nextLine();
        System.out.println("月租");
        int rent=scanner.nextInt();
        scanner.nextLine();
        System.out.println("状态");
        String state=scanner.nextLine();
        if(houseList.getHouseNums()==houseList.houses.length){
            System.out.println("数组已满");
            System.out.println("失败");
            return;
        }
        houseList.setId(1);
        House house=new House(houseList.getId(),name,phone,address,rent,state);
        //将创建的房屋添加到数组
        houseList.setHouses(house,houseList.getHouseNums());
        System.out.println("成功");
        houseList.setHouseNums(houseList.getHouseNums()+1);
    }
}
